package com.ruoyi.eqmonitor.service;

import java.util.List;

import cn.hutool.json.JSONArray;
import com.baomidou.mybatisplus.extension.service.IService;
import com.ruoyi.eqmonitor.domain.OptDevice;
import com.ruoyi.eqmonitor.domain.OptDeviceMonitorConfig;
import com.ruoyi.eqmonitor.domain.OptDeviceMonitorLastData;
import com.ruoyi.eqmonitor.dtos.OptDeviceDto;
import org.springframework.transaction.annotation.Transactional;

/**
 * @author ruoyi
 * @date 2022-11-26
 */
public interface IOptDeviceMonitorConfigService extends IService<OptDeviceMonitorConfig>{

    public OptDeviceMonitorConfig selectOptDeviceMonitorConfigById(Long id);

    public List<OptDeviceMonitorConfig> selectOptDeviceMonitorConfigList(OptDeviceMonitorConfig optDeviceMonitorConfig);

    /**
     * 根据设备实体删除设备阈值
     * @param optDevices 设备实体列表
     */
    public int removeDeviceMonitorConfigByDevice(List<OptDevice> optDevices);

//    /**
//     * 根据设备初始化设备阈值配置
//     * @param optDevice 设备实体
//     * @return 新增行数
//     */
//    public int initDeviceMonitorConfigByDevice(OptDevice optDevice);

    /**
     * 更新阈值的设备编码
     * @param oldDeviceCode 原设备编码
     * @param newDeviceCode 新设备编码
     */
    public int updateDeviceCode(String oldDeviceCode, String newDeviceCode);

    public int saveDeviceMonitorConfig(OptDeviceMonitorConfig optDeviceMonitorConfig);

    public int updateDeviceMonitorConfigById(OptDeviceMonitorConfig optDeviceMonitorConfig);

    public int removeDeviceMonitorConfigByIds(List<Long> ids);

    /**
     * 获取阈值redis hkey
     * @param deviceCode 设备编码
     * @return redis hkey
     */
    public String getRedisHKey(String deviceCode);

    public int changeStatus(OptDeviceMonitorConfig optDeviceMonitorConfig);

    /**
     * 校验阈值并报警 设备参数
     * @param optDeviceDto 设备实体
     * @param messageArray 消息数组
     */
    public void validateConfigAndDoAlarm(OptDeviceDto optDeviceDto, JSONArray messageArray);
    public void validateConfigAndDoAlarm(OptDeviceDto optDeviceDto, OptDeviceMonitorLastData monitorData);

    /**
     * 根据设备编码获取预警阈值
     * @param deviceCode 设备编码
     */
    OptDeviceMonitorConfig getByDeviceCode(String deviceCode,String monitorCode);

}
